package com.cn.suplayer.ui;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.cn.suplayer.R;
import com.cn.suplayer.bean.VideoDirectories;

import java.util.List;

/**
 * Created by ZLM on 2016/6/16.
 */
public class MainListViewAdapter extends BaseAdapter {
    private Context context;
    private List<VideoDirectories> data;

    public MainListViewAdapter(Context context, List<VideoDirectories> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_mainlistview, null);
            holder = new Holder();
            holder.img = (ImageView) convertView.findViewById(R.id.folderIcon);
            holder.title = (TextView) convertView.findViewById(R.id.folderName);
            holder.info = (TextView) convertView.findViewById(R.id.folderInfo);
            convertView.setTag(holder);
        } else {
            //holder.img
            holder = (Holder) convertView.getTag();
        }
        holder.title.setText("目录："+data.get(position).getName());
        holder.info.setText("数量："+data.get(position).getCount()+"");
        return convertView;

    }

    class Holder {
        ImageView img;
        TextView title;
        TextView info;
    }


}
